package com.punai.evaluationSystem.incomeDataEvalute.controller;

import com.punai.common.core.domain.AjaxResult;
import com.punai.evaluationSystem.incomeDataEvalute.bo.IncomeDataEvaluteBo;
import com.punai.evaluationSystem.incomeDataEvalute.domain.EvaluationResultsSr;
import com.punai.evaluationSystem.incomeDataEvalute.service.IncomeLrEvaluteService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.page.TableDataInfo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 收入利润评价
 * 
 * @author tj
 * @date 2023-04-18
 */
@RestController
@RequestMapping("/incomeDataEvalute/lrEvalute")
public class IncomeLrEvaluteController extends BaseController
{
    @Autowired
    private IncomeLrEvaluteService incomeLrEvaluteService;

    /**
     * 查询结果列表
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/resultList")
    public TableDataInfo list(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        List<EvaluationResultsSr> list = incomeLrEvaluteService.initResultsSrTable(incomeDataEvaluteBo);
        return getDataTable(list);
    }

    /**
     * 保存资产库
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:edit')")
    @PostMapping("/saveAssetLibrary")
    public AjaxResult saveAssetLibrary(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        int i = incomeLrEvaluteService.saveAssetLibrary(incomeDataEvaluteBo.getList());
        return toAjax(i);
    }

    /**
     * 查询清洗数据列表
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/cleanDataList")
    public TableDataInfo cleanDataList(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        return getDataTable(incomeLrEvaluteService.initCleanDataTable(incomeDataEvaluteBo));
    }

    /**
     * 查询清洗数据列表
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/cleanDataEvaluteList")
    public TableDataInfo cleanDataEvaluteList(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        return incomeLrEvaluteService.initCleanDataEvaluteTable(incomeDataEvaluteBo);
    }

    /**
     * 详情表格
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/initTableDetailInfoData")
    public TableDataInfo initTableDetailInfoData(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        return getDataTable(incomeLrEvaluteService.initTableDetailInfoData(incomeDataEvaluteBo));
    }

    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/cleanDataInfoIdList")
    public TableDataInfo cleanDataInfoIdList(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        return getDataTable(incomeLrEvaluteService.cleanDataInfoIdList(incomeDataEvaluteBo));
    }

    /**
     * 重新计算
     * @param incomeDataEvaluteBo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/recalculation")
    public AjaxResult recalculation(IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        return AjaxResult.success(incomeLrEvaluteService.recalculation(incomeDataEvaluteBo));
    }

    /**
     * 保存评价价格
     * @param incomeDataEvaluteBo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/saveEvaluationPrice")
    public AjaxResult saveEvaluationPrice(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        int i = incomeLrEvaluteService.saveEvaluationPrice(incomeDataEvaluteBo);
        return toAjax(i);
    }

    /**
     * 修改评价价格
     * @param incomeDataEvaluteBo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:edit')")
    @PostMapping("/updateEvaluationPrice")
    public AjaxResult updateEvaluationPrice(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        int i = incomeLrEvaluteService.updateEvaluationPrice(incomeDataEvaluteBo);
        return toAjax(i);
    }

    /**
     * 查看详情列表
     */
    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/initEvaluteDataList")
    public TableDataInfo initEvaluteDataList(@RequestBody IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        return getDataTable(incomeLrEvaluteService.initEvaluteDataList(incomeDataEvaluteBo));
    }

    @PreAuthorize("@ss.hasPermi('incomeDataEvalute:lrEvalute:list')")
    @PostMapping("/evaluteDataInfoIdList")
    public TableDataInfo evaluteDataInfoIdList(IncomeDataEvaluteBo incomeDataEvaluteBo)
    {
        incomeDataEvaluteBo.setCompanyId(getCompanyId());
        return getDataTable(incomeLrEvaluteService.evaluteDataInfoIdList(incomeDataEvaluteBo));
    }
}
